package com.h819.core.web.struts2;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @Title: BaseActionExamples.java
 * @Description: TODO(添加描述)
 * @author H819
 * @date 2010-3-14
 * @version V1.0
 */
public class BaseActionExamples extends ActionSupport implements SessionAware,
		ServletRequestAware, ServletResponseAware {

	private static final long serialVersionUID = 7620009925942346125L;

	HttpServletRequest request;
	HttpServletResponse response;
	SessionMap session;

	public String execute() throws Exception {
		return null;
	}

	// 获取request,response,session方式一，非IoC方式，不用实现SessionAware,
	// ServletRequestAware, ServletResponseAware
	// ActionContext context = ActionContext.getContext();
	// HttpServletRequest request = (HttpServletRequest)
	// context.get(ServletActionContext.HTTP_REQUEST);
	// HttpServletResponse response = (HttpServletResponse)
	// context.get(ServletActionContext.HTTP_RESPONSE);
	// Map session = context.getSession();
	// SessionMap session = (SessionMap) context.get(ActionContext.SESSION);

	// 获取request,response,session方式一，IoC方式，必须实现SessionAware,
	// ServletRequestAware, ServletResponseAware
	public void setSession(Map map) {
		this.session = (SessionMap) map;
	}

	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
